--- getty_ps/OLD/main.c	Sun Feb 20 00:22:31 1994
+++ getty_ps/main.c	Mon Jan 24 01:20:38 1994
@@ -124,6 +124,7 @@
 
 #ifdef FIDO
 	fido =		(char *) NULL;		/* fido program */
+	emsi =		(char *) NULL;		/* emsi yes or no */
 #endif /* FIDO */
 
 #ifdef SCHED
@@ -337,6 +338,7 @@
 	if((p = defvalue(def, "INITLINE"))) InitDevice = p;
 #ifdef FIDO
 	fido = defvalue(def, "FIDO");
+	emsi = defvalue(def, "EMSI");
 #endif /* FIDO */
 
 #ifdef SCHED
@@ -526,8 +528,13 @@
 
 /* now, the init device is opened ONLY if INIT or WAITCHAR is requested
 */
+/* This is a bad idea. Because any previous programs could leave the tty
+   in unpredictable stty state (the worst is CLOCAL left ON), we would
+   better comment out the following "if" to run the initialization pass
+   on every invocation, regarless of the presence of "init" or "waitchar" 
 
 	if((init) || (waitchar)) {
+*/
 		debug3(D_RUN, "opening init line: %s\n", initdevname);
 		while((fd = open(initdevname, O_RDWR | O_NDELAY)) < 0) {
 			if(errno == EBUSY)
@@ -554,6 +561,7 @@
 		setbuf(stdout, (char *) NULL);
 		setbuf(stderr, (char *) NULL);
 
+		settermio(&(gtab->itermio), INITIAL);
 
 		flags = fcntl(STDIN, F_GETFL, 0);
 		(void) fcntl(STDIN, F_SETFL, flags & ~O_NDELAY);
@@ -578,7 +586,9 @@
 
 			settermio(&(gtab->itermio), INITIAL);
 		}
+/*
 	}
+*/
 
 /* set the alarm if requested
 */
@@ -619,11 +629,17 @@
 		}
 	}
 
+/* Again, as we opened the line anyway, here we must close it regardless
+   of the "init" and "waitchar"
+
 	if((init) || (waitchar)) {
+*/
 		(void) close(0);
 		(void) close(1);
 		(void) close(2);
+/*
 	}
+*/
 }
 
 
@@ -862,8 +878,12 @@
 #endif /* ISSUE */
 
 login_prompt:
-		(void) Fputs(gtab->login, stdout);
 		(void) ioctl(STDIN, TCFLSH, 0);
+#ifdef FIDO
+	if (emsi && (strcmp(emsi,"yes") == 0)) 
+		(void) Fputs("**EMSI_REQA77E\r", stdout);
+#endif
+		(void) Fputs(gtab->login, stdout);
 		if(TimeOut > 0) {
 			(void) signal(SIGALRM, timeout);
 			(void) alarm((unsigned) TimeOut);
--- getty_ps/OLD/main.h	Mon Apr 12 00:22:13 1993
+++ getty_ps/main.h	Thu Oct 28 22:54:57 1993
@@ -108,6 +108,7 @@
 
 #ifdef FIDO
 EXTERN char		*fido;		/* fido program */
+EXTERN char		*emsi;		/* fido program */
 #endif /* FIDO */
 
 #ifdef SCHED
--- getty_ps/OLD/funcs.c	Sun Apr 18 00:28:04 1993
+++ getty_ps/funcs.c	Sat Feb 19 02:55:44 1994
@@ -66,6 +66,9 @@
 /* SMR - gcc uses signed characters, so I cast the following */
 #define	AUTOBD	((char)0376)	/* marker for AutoBaud digits */
 
+extern char *fido;
+extern char *emsi;
+
 char	*unquote();
 int	expect(), send();
 boolean	expmatch();
@@ -662,6 +665,8 @@
 	register int count;
 	register int lower = 0;
 	register int upper = 0;
+	int tsynccount=0;
+	int yoohoocount=0;
 	char ch, *p;
 	ulong lflag;
 
@@ -697,7 +702,8 @@
 	do {
 		if (read(STDIN, &ch, 1) != 1)	/* nobody home */
 			exit(0);
-		if ((ch = (char) ((int) ch & 0177)) == CEOF)
+		/* if ((ch = (char) ((int) ch & 0177)) == CEOF) */
+		if (ch == CEOF)
 			if (p == name)		/* ctrl-d was first char */
 				exit(0);
 		if (ch == CQUIT)		/* user wanted out, i guess */
@@ -706,14 +712,18 @@
 			debug2(D_GETL, "returned (BADSPEED)\n");
 			return(BADSPEED);
 		}
-		if (ch == TSYNC) {
-			name = "tsync";
+#ifdef FIDO
+		if (fido && (ch == TSYNC))
+		if (tsynccount++ > 1) {
+			strcpy(name,"tsync");
 			return (FIDOCALL);
 		}
-		if (ch == YOOHOO) {
-			name = "yoohoo";
+		if (fido && (ch == YOOHOO))
+		if (yoohoocount++ > 1) {
+			strcpy(name,"yoohoo");
 			return (FIDOCALL);
 		}
+#endif
 		if (!(lflag & ECHO)) {
 			(void) putc(ch, stdout);
 			(void) fflush(stdout);
@@ -734,7 +744,13 @@
 			}
 			p = name;
 			count = 0;
-		} else {
+#ifdef FIDO
+		} else if (((unsigned)ch >= ' ') &&
+			   (ch != TSYNC) &&
+			   (ch != YOOHOO)) {
+#else
+		} else if ((unsigned)ch >= ' ') {
+#endif
 			*p++ = ch;
 			count++;
 			if (islower(ch))
@@ -744,7 +760,7 @@
 		}
 	} while ((ch != '\n') && (ch != '\r') && (count < size));
 
-	*(--p) = '\0';	/* terminate buffer */
+	*(p) = '\0';	/* terminate buffer */
 
 	if (ch == '\r') {
 		(void) putc('\n', stdout);
@@ -756,10 +772,26 @@
 		(void) fflush(stdout);
 	}
 
-	if (strlen(name) == 0) {
+	if (strlen(name) == strspn(name," ")) {
 		debug2(D_GETL, "returned (NONAME)\n");
 		return(NONAME);
 	}
+
+#ifdef FIDO
+	for (p=name;(*p) && (*p == '*');p++);
+	if ((strncmp(p,"EMSI_",5) == 0) ||
+	    (strncmp(p,"emsi_",5) == 0))
+	if (emsi && (strcmp(emsi,"yes") == 0))
+	{
+		debug2(D_GETL, "returned EMSI call\n");
+		return(FIDOCALL);
+	}
+	else
+	{
+		debug2(D_GETL, "EMSI call,return (NONAME)\n");
+		return(NONAME);
+	}
+#endif
 
 	if (upper && !lower) {
 #ifdef	WARNCASE
